package gameEngine;

import java.util.Scanner;

import Exceptions.IncorrectInputException;
import classInterfaces.IPlayer;

public class Player implements IPlayer{

	private String name;
	private int points;
	
  public Player(String name) {
		super();
		this.name = name;
	}
   
  public String getName() {
		return name;
	}

	public int getPoints() {
		return points;
	}
	
  public void setPoints(int points) {
		this.points = points;
	}

	public boolean iSurrender() {
		return true;
	}

	public String[] enterCoordinates() throws IncorrectInputException{
		
		Scanner sc = new Scanner(System.in);

		String[] coords = new String[3];

//		for (int i = 0; i < 3; i++) {
//			
//			//coords[i] = sc.hasNext();
//			
//		}
		
		coords[0] =sc.next();
		if (isNumeric(coords[0])){
			
		} else {
			System.out.println("X-coordinates have to be from Numberic.");
			System.out.println("Please enter new coordinates: ");
			enterCoordinates();
		}
		
		coords[1] =sc.next();
		if (isNumeric(coords[1])){
			
		} else {
			System.out.println("Y-coordinates have to be from Numberic.");
			System.out.println("Please enter new coordinates: ");
			enterCoordinates();
		}
		
		String dirrection=sc.next();
		coords[2]=dirrection.substring(0,1);
		
		if (coords[2].equals("r")||coords[2].equals("u")||coords[2].equals("R")||coords[2].equals("U")){
			
		} else {
			System.out.println("Last character should be R or U.");
			System.out.println("Please enter new coordinates: ");
			enterCoordinates();
		}
		
		sc.close();
		
		return coords;

	}
	
	public static boolean isNumeric(String str)
	{
	  return str.matches("-?\\d+(\\.\\d+)?");  //match a number with optional '-' and decimal.
	}
	
	public String playerName() {

		return getName();
	}

	@Override
	public boolean isSurrender() {
		// TODO Auto-generated method stub
		return false;
	}
	 
}